<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>实验教学管理系统</title>
	<link href="css/bootstrap.min.css" rel="stylesheet" />
	<script src="js/jquery-3.2.0.min.js" ></script>
	<script src="js/bootstrap.min.js" ></script>
	<script src="js/config.js" ></script>
	<script src="js/common.js" ></script>
</head>
<body style="padding:100px;">
	<div class="panel panel-primary">
		<div class="panel-heading" id="tableTitle">课表</div>
		
		<table class="table">
			<thead>
				<th>时间</th>
				<th>周一</th>
				<th>周二</th>
				<th>周三</th>
				<th>周四</th>
				<th>周五</th>
				<th>周六</th>
				<th>周日</th>
			</thead>
			<tbody id="tableBody">
				<tr>
					<th>12节</th>
					<td id="s1_1"></td>
					<td id="s1_2"></td>
					<td id="s1_3"></td>
					<td id="s1_4"></td>
					<td id="s1_5"></td>
					<td id="s1_6"></td>
					<td id="s1_7"></td>
				</tr>
				<tr>
					<th>34节</th>
					<td id="s2_1"></td>
					<td id="s2_2"></td>
					<td id="s2_3"></td>
					<td id="s2_4"></td>
					<td id="s2_5"></td>
					<td id="s2_6"></td>
					<td id="s2_7"></td>
				</tr>
				<tr>
					<th>56节</th>
					<td id="s3_1"></td>
					<td id="s3_2"></td>
					<td id="s3_3"></td>
					<td id="s3_4"></td>
					<td id="s3_5"></td>
					<td id="s3_6"></td>
					<td id="s3_7"></td>
				</tr>
				<tr>
					<th>78节</th>
					<td id="s4_1"></td>
					<td id="s4_2"></td>
					<td id="s4_3"></td>
					<td id="s4_4"></td>
					<td id="s4_5"></td>
					<td id="s4_6"></td>
					<td id="s4_7"></td>
				</tr>
			</tbody>
		</table>
	</div>
	<script>
	var $table = $('#tableBody');
	var initTd_r = function(r){
		var re = 1;
		switch(r){
		case '第1节~第2节':re=1;break;
		case '第3节~第4节':re=2;break;
		case '第5节~第6节':re=3;break;
		case '第7节~第8节':re=4;break;
		}
		return re;
	}
	var initTd_c = function(c){
		var re = 1;
		switch(c){
		case '周一':re=1;break;
		case '周二':re=2;break;
		case '周三':re=3;break;
		case '周四':re=4;break;
		case '周五':re=5;break;
		case '周六':re=6;break;
		case '周日':re=7;break;
		}
		return re;
	}
	var initTd = function(d){
		//第四周-周三-第1节~第2节
		var s = d.time.split('-');
		var c = initTd_c(s[1]);
		var r = initTd_r(s[2]);
		console.log(s,r,c);
		$table.find('#s'+r+'_'+c).append(d.pname + '<br/>'+d.rname+'<br/>'+s[0]+'<br/>');
	}
	var initTable = function(data){
		console.log(data);
		for(i in data){
			initTd(data[i]);	
		}
	}
	$.get(BASE_URL + "/scheduleSelect",{},function(res){
		initTable(res.data);
	},'json');
	</script>
</body>
</html>